const {
  getOrderService,
  getSortService,
  getbaseService,
  getProfitService,
} = require("../service/order.service");

class OrderController {
  // 获取利润
  async getProfit(ctx, next) {
    const res = await getProfitService();
    console.log(res[0]);
    ctx.body = res[0];
  }
  // 获取订单
  async getOrder(ctx, next) {
    // console.log(1);
    const res = await getOrderService();
    console.log(res);
    ctx.body = res;
  }

  // 获取数据报表nums
  async getSort(ctx, next) {
    const res = await getSortService();
    console.log(res);
    ctx.body = res;
  }

  async getbase(ctx, next) {
    console.log(ctx.request.params);
    const res = await getbaseService(ctx.request.params.id);
    // console.log(res);
    if (res.length >= 1)
      return (ctx.body = {
        meta: {
          status: 200,
        },
        msg: "查询发源地成功",
        data: res[0],
      });
    else {
      ctx.body = {
        meta: {
          status: 504,
        },
        msg: "查询发源地失败",
      };
    }
  }
}

module.exports = new OrderController();
